|
1
|
|
|
import {BaseEndpoint, QueryDateLimiter, QueryParameters} from './baseEndpoint'; |
|
2
|
|
|
import { |
|
3
|
|
|
TVAlternativeTitlesResponse, |
|
4
|
|
|
TVDetailsResponse, |
|
5
|
|
|
TVChangesResponse, |
|
6
|
|
|
TVContentRatingsResponse, |
|
7
|
|
|
TVCreditsResponse, |
|
8
|
|
|
TVEpisodeGroupsResponse, |
|
9
|
|
|
TVExternalIDResponse, |
|
10
|
|
|
TVImagesResponse, |
|
11
|
|
|
TVKeywordsResponse, |
|
12
|
|
|
TVRecommendationsResponse, |
|
13
|
|
|
TVReviewsResponse, |
|
14
|
|
|
TVScreenedTheatricallyResponse, |
|
15
|
|
|
TVSimilarResponse, |
|
16
|
|
|
TVTranslationsResponse, |
|
17
|
|
|
TVVideosResponse, |
|
18
|
|
|
TVAiringTodayResponse, |
|
19
|
|
|
TVOnTheAirResponse, |
|
20
|
|
|
TVPopularResponse, |
|
21
|
|
|
TVTopRatedResponse, |
|
22
|
|
|
} from '../interfaces/tv'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* TV Endpoint Class |
|
26
|
|
|
*/ |
|
27
|
|
|
export class TV extends BaseEndpoint { |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get the primary TV show details by id. |
|
31
|
|
|
* @param { number } tvID |
|
32
|
|
|
* @return { Promise<TVDetailsResponse> } |
|
33
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-details |
|
34
|
|
|
* TODO: Add the `appends_to_response` option |
|
35
|
|
|
*/ |
|
36
|
|
|
public async details(tvID: number): Promise<TVDetailsResponse> { |
|
37
|
|
|
return this.sendGetRequest(`tv/${tvID}`); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Returns all of the alternative titles for a TV show. |
|
42
|
|
|
* @param { number } tvID |
|
43
|
|
|
* @return { Promise<TVAlternativeTitlesResponse> } |
|
44
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-alternative-titles |
|
45
|
|
|
*/ |
|
46
|
|
|
public async alternativeTitles(tvID: number): Promise<TVAlternativeTitlesResponse> { |
|
47
|
|
|
return this.sendGetRequest(`tv/${tvID}/alternative_titles`); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get the changes for a TV show. By default only the last 24 hours are returned. |
|
52
|
|
|
* You can query up to 14 days in a single query by using the `start_date` and `end_date` query parameters. |
|
53
|
|
|
* @param { number } tvID |
|
54
|
|
|
* @param { QueryDateLimiter } parameters |
|
55
|
|
|
* @return { Promise<TVChangesResponse> } |
|
56
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-changes |
|
57
|
|
|
*/ |
|
58
|
|
|
public async changes(tvID: number, parameters: QueryDateLimiter = {}): Promise<TVChangesResponse> { |
|
59
|
|
|
return this.sendGetRequest(`tv/${tvID}/changes`, parameters as QueryParameters); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Get the list of content ratings (certifications) that have been added to a TV show. |
|
64
|
|
|
* @param { number } tvID |
|
65
|
|
|
* @return { Promise<TVContentRatingsResponse> } |
|
66
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-content-ratings |
|
67
|
|
|
*/ |
|
68
|
|
|
public async contentRatings(tvID: number): Promise<TVContentRatingsResponse> { |
|
69
|
|
|
return this.sendGetRequest(`tv/${tvID}/content_ratings`); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get the credits (cast and crew) that have been added to a TV show. |
|
74
|
|
|
* @param { number } tvID |
|
75
|
|
|
* @return { Promise<TVCreditsResponse> } |
|
76
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-credits |
|
77
|
|
|
*/ |
|
78
|
|
|
public async credits(tvID: number): Promise<TVCreditsResponse> { |
|
79
|
|
|
return this.sendGetRequest(`tv/${tvID}/credits`); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get all of the episode groups that have been created for a TV show. |
|
84
|
|
|
* @param { number } tvID |
|
85
|
|
|
* @return { Promise<TVEpisodeGroupsResponse> } |
|
86
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-episode-groups |
|
87
|
|
|
*/ |
|
88
|
|
|
public async episodeGroup(tvID: number): Promise<TVEpisodeGroupsResponse> { |
|
89
|
|
|
return this.sendGetRequest(`tv/${tvID}/episode_groups`); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get the external ids for a TV show. |
|
94
|
|
|
* @param { number } tvID |
|
95
|
|
|
* @return { Promise<TVExternalIDResponse> } |
|
96
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-external-ids |
|
97
|
|
|
*/ |
|
98
|
|
|
public async externalIDs(tvID: number): Promise<TVExternalIDResponse> { |
|
99
|
|
|
return this.sendGetRequest(`tv/${tvID}/external_ids`); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get the images that belong to a TV show. |
|
104
|
|
|
* @param { number } tvID |
|
105
|
|
|
* @param { QueryParameters } parameters |
|
106
|
|
|
* @return { Promise<TVImagesResponse> } |
|
107
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-images |
|
108
|
|
|
*/ |
|
109
|
|
|
public async images(tvID: number, parameters: QueryParameters = {}): Promise<TVImagesResponse> { |
|
110
|
|
|
return this.sendGetRequest(`tv/${tvID}/images`, parameters); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Get the keywords that have been added to a TV show. |
|
115
|
|
|
* @param { number } tvID |
|
116
|
|
|
* @return { Promise<TVKeywordsResponse> } |
|
117
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-keywords |
|
118
|
|
|
*/ |
|
119
|
|
|
public async keywords(tvID: number): Promise<TVKeywordsResponse> { |
|
120
|
|
|
return this.sendGetRequest(`tv/${tvID}/keywords`); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Get the list of TV show recommendations for this item. |
|
125
|
|
|
* @param { number } tvID |
|
126
|
|
|
* @return { Promise<TVRecommendationsResponse> } |
|
127
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-recommendations |
|
128
|
|
|
*/ |
|
129
|
|
|
public async recommendations(tvID: number): Promise<TVRecommendationsResponse> { |
|
130
|
|
|
return this.sendGetRequest(`tv/${tvID}/recommendations`); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get the reviews for a TV show. |
|
135
|
|
|
* @param { number } tvID |
|
136
|
|
|
* @return { Promise<TVReviewsResponse> } |
|
137
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-reviews |
|
138
|
|
|
*/ |
|
139
|
|
|
public async reviews(tvID: number): Promise<TVReviewsResponse> { |
|
140
|
|
|
return this.sendGetRequest(`tv/${tvID}/reviews`); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Get a list of seasons or episodes that have been screened in a film festival or theatre. |
|
145
|
|
|
* @param { number } tvID |
|
146
|
|
|
* @return { Promise<TVScreenedTheatricallyResponse> } |
|
147
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-screened-theatrically |
|
148
|
|
|
*/ |
|
149
|
|
|
public async screenedTheatrically(tvID: number): Promise<TVScreenedTheatricallyResponse> { |
|
150
|
|
|
return this.sendGetRequest(`tv/${tvID}/screened_theatrically`); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Get a list of similar TV shows. |
|
155
|
|
|
* These items are assembled by looking at keywords and genres. |
|
156
|
|
|
* @param { number } tvID |
|
157
|
|
|
* @return { Promise<TVSimilarResponse> } |
|
158
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-similar-tv-shows |
|
159
|
|
|
*/ |
|
160
|
|
|
public async similar(tvID: number): Promise<TVSimilarResponse> { |
|
161
|
|
|
return this.sendGetRequest(`tv/${tvID}/similar`); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Get a list of the translations that exist for a TV show. |
|
166
|
|
|
* @param { number } tvID |
|
167
|
|
|
* @return { Promise<TVTranslationsResponse> } |
|
168
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-similar-tv-shows |
|
169
|
|
|
*/ |
|
170
|
|
|
public async translations(tvID: number): Promise<TVTranslationsResponse> { |
|
171
|
|
|
return this.sendGetRequest(`tv/${tvID}/translations`); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Get the videos that have been added to a TV show. |
|
176
|
|
|
* @param { number } tvID |
|
177
|
|
|
* @return { Promise<TVTranslationsResponse> } |
|
178
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-videos |
|
179
|
|
|
*/ |
|
180
|
|
|
public async videos(tvID: number): Promise<TVVideosResponse> { |
|
181
|
|
|
return this.sendGetRequest(`tv/${tvID}/videos`); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Get the most newly created TV show. |
|
186
|
|
|
* This is a live response and will continuously change. |
|
187
|
|
|
* @return { Promise<TVTranslationsResponse> } |
|
188
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-latest-tv |
|
189
|
|
|
*/ |
|
190
|
|
|
public async latest(): Promise<TVDetailsResponse> { |
|
191
|
|
|
return this.sendGetRequest(`tv/latest`); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Get a list of TV shows that are airing today. |
|
196
|
|
|
* This query is purely day based as we do not currently support airing times. |
|
197
|
|
|
* @return { Promise<TVAiringTodayResponse> } |
|
198
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-airing-today |
|
199
|
|
|
*/ |
|
200
|
|
|
public async airingToday(): Promise<TVAiringTodayResponse> { |
|
201
|
|
|
return this.sendGetRequest(`tv/airing_today`); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* Get a list of shows that are currently on the air. |
|
206
|
|
|
* This query looks for any TV show that has an episode with an air date in the next 7 days. |
|
207
|
|
|
* @return { Promise<TVOnTheAirResponse> } |
|
208
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-tv-airing-today |
|
209
|
|
|
*/ |
|
210
|
|
|
public async onTheAir(): Promise<TVOnTheAirResponse> { |
|
211
|
|
|
return this.sendGetRequest(`tv/on_the_air`); |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
/** |
|
215
|
|
|
* Get a list of the current popular TV shows on TMDb. This list updates daily. |
|
216
|
|
|
* @return { Promise<TVPopularResponse> } |
|
217
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-popular-tv-shows |
|
218
|
|
|
*/ |
|
219
|
|
|
public async popular(): Promise<TVPopularResponse> { |
|
220
|
|
|
return this.sendGetRequest(`tv/popular`); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* Get a list of the top rated TV shows on TMDb. |
|
225
|
|
|
* @return { Promise<TVTopRatedResponse> } |
|
226
|
|
|
* @see https://developers.themoviedb.org/3/tv/get-top-rated-tv |
|
227
|
|
|
*/ |
|
228
|
|
|
public async topRated(): Promise<TVTopRatedResponse> { |
|
229
|
|
|
return this.sendGetRequest(`tv/top_rated`); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
} |
|
233
|
|
|
|